package com.yanqu.road.server.cmd.activity.mammonhall;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.activity.MammonHallProto;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.mammonhall.MammonHallMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

import java.util.ArrayList;
import java.util.List;


@Cmd(code = GameProtocol.S_MAMMON_HALL_RANK_TOP, desc = "财神殿-榜首")
public class MammonHallRankTopCmd extends AbstractCommand {

    List<Integer> typeList = new ArrayList<>();

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        MammonHallProto.MammonHallRankTopReqMsg reqMsg = MammonHallProto.MammonHallRankTopReqMsg.parseFrom(packet.getBytes());
        typeList = reqMsg.getTypeList();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        //上分组跨服取值
        MammonHallProto.CrossMammonHallRankTopReqMsg.Builder reqMsg = MammonHallProto.CrossMammonHallRankTopReqMsg.newBuilder();
        reqMsg.addAllType(typeList);
        UserBaseInfo userBaseInfo = UserMgr.parseUserBaseInfo(player.getUserInfo(), GameServer.getInstance().getServerId());
        reqMsg.setUserInfo(PlayerBasePb.parsePlayerBaseTempMsg(userBaseInfo));
        reqMsg.setBeginTime(MammonHallMgr.getActivityBeginTime());
        player.sendPacket(Protocol.C_MAMMON_HALL_RANK_TOP, reqMsg);
    }


    @Override
    public void sendData(GamePlayer player) {

    }
}
